﻿using Essensoft.Paylinks.Alipay.Client;
using Essensoft.Paylinks.Alipay.Payments.Model;
using Essensoft.Paylinks.Alipay.Payments.Request;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pay.Core.AliPayCore
{
    /// <summary>
    /// 电脑网站支付
    /// </summary>
    /// <param name="client"></param>
    /// <param name="options"></param>
    public class PCWebPay(IAlipayClient client, AlipayClientOptions options)
    {
        public async Task<string> PayAsync(AlipayTradePagePayBizModel model)
        {
            model = new AlipayTradePagePayBizModel
            {
                OutTradeNo = DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff"),
                TotalAmount = "0.01",
                Subject = "电脑网站支付测试",
                ProductCode = "FAST_INSTANT_TRADE_PAY",
                NotifyUrl = "https://www.domain.com/Alipay/Payments/Notify/TradeResult"
            };
            var request = new AlipayTradePagePayRequest();
            request.SetBizModel(model);
            var response = await client.PageExecuteAsync(request, options);
            return response;
        }
    }
}
